/*
Source : https://leetcode.com/problems/single-number/
Author : nflush@outlook.com
Date   : 2016-07-14
*/

/*
136. Single Number
 ?  

Question Editorial Solution  
 My Submissions 




?Total Accepted: 138034
?Total Submissions: 271871
?Difficulty: Medium



Given an array of integers, every element appears twice except for one. Find that single one.

Note:
 Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? 



Subscribe to see which companies asked this question
*/
class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int x = 0;
        for(int n:nums){
            x ^=n;
        }
        return x;
    }
};